home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / kiss-0.11 / kiss-0 / kiss / src / domount.c < prev    next >
C/C++ Source or Header  |  1995-03-23  |  951b  |  41 lines

  1. #include "kiss.h"
  2.  
  3. int domount (Stringstack s)
  4. {
  5.     register int
  6.     opt;
  7.     register char
  8.     *type = NULL;
  9.  
  10.     while ( (opt = getopt (s.nstr, s.str, "t:h")) != -1 )
  11.     switch (opt)
  12.     {
  13.         case 't':
  14.         if (! (type = optarg))
  15.             error ("missing type after \"-t\"");
  16.         break;
  17.         default:
  18.         case 'h':
  19.         error ("Bad commandline.\n"
  20.                "Usage: %s [-t type] [-r] device directory\n"
  21.                "Where:\n"
  22.                "    -t type   : mount as type, e.g. ext2, minix\n"
  23.                "    device    : device to mount\n"
  24.                "    directory : mount point\n"
  25.                , progname);
  26.     }
  27.  
  28.     if (s.nstr - optind != 2)
  29.     error ("illegal number of arguments");
  30.  
  31.     if (! type)
  32.     error ("need \"-t type\" specification");
  33.  
  34.     if (mount (s.str [optind], s.str [optind + 1], type, 1, 0))
  35.     error ("problem mounting \"%s\" on \"%s\" (type \"%s\")",
  36.            s.str [optind + 1], s.str [optind], type);
  37.  
  38.     printf ("Note: /etc/mtab not updated.\n");
  39.     return (0);
  40. }
  41.